
class UsercashPlugin:
	def __init__(self):
		# put all the links this plugins supports here - it will be used to filter supported URLs
		self.supported_sites = ['usercash.com']
		self.supported_urls = self.supported_sites

	def get(self, url):
		"""Get a single file from usercash"""
		titl_pat = '<TITLE>'
		remote_url = None
		for line in urllib2.urlopen(url).read().splitlines():
			if line.find(titl_pat) != -1:
				remote_url = line.split(titl_pat)[1].split('</TITLE>')[0]
				break

		if not remote_url:
			raise CantDownload('Error occured while trying to download')
		get_with_retry(remote_url)

	def url_matches(self, url):
		"""Check whether we support this URL"""
		for l in self.supported_urls:
			if url.find(l) != -1:
				return True
		return False

	def version(self):
		"""Return plugin version - when interface changes, the version changes"""
		return 1

modules = [UsercashPlugin()]
